package com.github.shiqiyue.app.modules.dbms.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import com.github.shiqiyue.app.common.entity.BaseEntity;
import com.github.shiqiyue.app.common.enums.IBaseEnum;
import com.github.shiqiyue.app.modules.sys.entity.User;
import lombok.Data;

/**
 * <p>
 * 数据库
 * </p>
 *
 * @author wenyao.wu
 * @since 2019-08-06
 */
@Data

@TableName("dbms_database")
public class Database extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 创建人ID
     */
    private Long addUserId;

    /**
     * 修改人ID
     */
    private Long editUserId;

    /**
     * 数据库地址
     */
    private String url;

    /**
     * 数据库类型，1-mysql
     */
    private DbType dbType;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 名称
     */
    private String name;

    /**
     * 备注
     */
    private String remark;

    /***
     * 创建人
     */
    @TableField(exist = false)
    private User addUser;

    /***
     * 修改人
     */
    @TableField(exist = false)
    private User editUser;


    public static final String ADD_USER_ID = "add_user_id";

    public static final String EDIT_USER_ID = "edit_user_id";

    public static final String URL = "url";

    public static final String DB_TYPE = "db_type";

    public static final String USERNAME = "username";

    public static final String PASSWORD = "password";

    public static final String NAME = "name";

    public static final String REMARK = "remark";

    /***
     * 数据库类型
     */
    public enum DbType implements IBaseEnum {

        /***
         * mysql
         */
        MYSQL("mysql", 1)
        ;

        private String name;

        private Integer value;

        DbType(String name, Integer value) {
            this.name = name;
            this.value = value;
        }

        @Override
        public String getName() {
            return name;
        }

        @Override
        public Integer getValue() {
            return value;
        }

        @Override
        public String toString() {
            return value.toString();
        }

    }

}
